#pragma once
#include <vector>

template <class T>
class	growvector
{
private:
	std::vector<T>	vec;
	unsigned int	count;
public:
	void	clear(){
		count=0;
	}
	inline void	push_back(const T&	elem){
		if(count<vec.size()){
			vec[count++]=elem;
		}else{
			vec.push_back(elem);
			count++;
		}
	}
	
	inline T& operator[](unsigned int index){
		return vec[index];
	}
	
	void	removeAll(T& elem){
		unsigned int wr=0;
		unsigned int nrem=0;
		for(unsigned int t=0;t<count;t++){
			if(vec[t]!=elem)wr++; else nrem++;
			if(wr>t)vec[t]=vec[wr++];
		}
		count-=nrem;
	}

	inline T& pop_back(T&	elem){
		return vec[--count];
	}
	inline unsigned int size(){
		return count;
	}
	growvector<T>(){
		count=0;
	}
};
